#!/bin/bash
echo `date`
echo ' check_redis.sh start'

function check(){
    process_name="redis-server"

    # 指定要查询和杀死的进程名称
    pid=`ps -ef | grep $process_name | grep -v grep | awk '{print $2}'`

    if [ -z "$pid" ]; then
        echo "No process found with name $process_name"
        nohup redis-server /etc/redis.conf &
    else
        # 杀死进程
        echo "success"
    fi
}

check

echo 'end'
